Running Macro in Excel from DXL

Hello,

  i'm a DOORS and DXL rookie and am having problems with running a macro from dxl. I need to open an Excel file in dxl, run a macro on it. I am able to open the file but cannot run the macro. Also, I am not able to find the macro that I have saved, when I open a new instance of Excel with oleCreateAutoObject. This is not the case when i open the file with oleGetAutoObject(but I would like to open a new instance).

I have attached my fairly simple code below, since i couldn't find the code tags. Any help would be appreciated


MaRaya - Wed Oct 16 05:24:34 EDT 2013

Re: Running Macro in Excel from DXL
llandale - Wed Oct 16 11:27:55 EDT 2013

I'm guessing:
Change:  oleMethod(oleWorkbook, "Run", macroArgs)
to:             oleMethod(oleExcel, "Run", macroArgs)

I'm not good at this and have struggled controling MS-Word, but running a Word Macro demands the "Word" application object, not the "Document" object.

-Louie

Re: Running Macro in Excel from DXL
MaRaya - Wed Oct 16 14:38:58 EDT 2013

llandale - Wed Oct 16 11:27:55 EDT 2013

I'm guessing:
Change:  oleMethod(oleWorkbook, "Run", macroArgs)
to:             oleMethod(oleExcel, "Run", macroArgs)

I'm not good at this and have struggled controling MS-Word, but running a Word Macro demands the "Word" application object, not the "Document" object.

-Louie

Thanks for the suggestion Louie.. tried it but it doesn't work..

Re: Running Macro in Excel from DXL
Adamarla - Thu Oct 17 02:53:26 EDT 2013

 

clear(macroArgs)
 
put(macroArgs, "Macro", NAMEOFMACRO)
 
put(macroArgs, "Arg1", ARGUMENT1) // Optional
 
put(macroArgs, "Arg2", ARGUMENT2) // Optional
 
// ... up to maximum of "Arg30"
 
oleMethod(oleExcel, "Run", macroArgs)

-Adam

Re: Running Macro in Excel from DXL
MaRaya - Thu Oct 17 03:15:26 EDT 2013

Louie,

 

  it works.. my bad!! I didn't save my excel file as xlsm.. so i need to save it as a macro enabled file and then make the change you suggested to make it work.. thanks..

 

Adamaria,

thanks for your response too..